<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: lenovo
  Date: 2020/6/10
  Time: 14:20
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Step2</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/jquery-1.11.3.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">

    <div class="row">
        <nav class="navbar navbar-inverse">
            <div class="container-fluid">
                <!-- Brand and toggle get grouped for better mobile display -->
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                            data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">步骤2</a>
                </div>

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav">

                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                               aria-haspopup="true" aria-expanded="false">导入<span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a href="uploadData.jsp">数据 </a></li>
                                <%--<li role="separator" class="divider"></li>
                                <li><a href="uploadModel.jsp">模型</a></li>--%>
                            </ul>
                        </li>

                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                               aria-haspopup="true" aria-expanded="false">导出<span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <c:if test="${(!(empty Optimation_flag))}">
                                    <li><a href="Charts.jsp">结果图</a></li>
                                </c:if>
                                <%--<li role="separator" class="divider"></li>
                                <li><a href="#">导出 </a></li>--%>
                            </ul>
                        </li>

                        <li><a href="Drop_table.jsp">删除表</a></li>

                    </ul>

                        <ul class="nav navbar-nav navbar-right">
                            <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                               aria-haspopup="true" aria-expanded="false">返回界面<span class="caret"></span></a>
                            <ul class="dropdown-menu">
                              <c:if test="${(!(empty DataUpload))}">
                                <li><a href="DataShow.jsp">数据</a></li>
                              </c:if>
                              <c:if test="${(!(empty ModelUpload))}">
                                <li><a href="ModelShow.jsp">模型</a></li>
                              </c:if>
                                <c:if test="${!(empty Caculate_flag)}">
                                    <li><a href="Step3.jsp">计算结果</a></li>
                                </c:if>
                                <c:if test="${!(empty Optimation_flag)}">
                                    <li><a href="Optimation.jsp">优化结果</a></li>
                                </c:if>

                            </ul>
                            </li>
                        </ul>

                </div>
            </div>
        </nav>
    </div>


    <div class="row FC">
        <div class="col-md-4 col-md-offset-4">

            <c:if test="${empty DataUpload}">
                <span class="FZ">请先导入数据</span>
                <br/>
                <br/>
                <br/>
            </c:if>

            <c:if test="${!(empty DataUpload)}">
                <span class="FZ">数据已导入至系统</span>
                <br/>
                <br/>
                <br/>
            </c:if>

            <c:if test="${!(empty DataUpload) && (empty ModelUpload)}">
                <form id="uo" action="/Java_web/UploadModel" method="post" enctype="multipart/form-data">
                    D1:<input type="text" name="D1" value="-15.0" placeholder="请输入D1值"/> <br/><br/>
                    D2:<input type="text" name="D2" value="-12.0" placeholder="请输入D2值"/> <br/><br/>
                    D3:<input type="text" name="D3" value="-9.0" placeholder="请输入D3值"/> <br/><br/>
                    D4:<input type="text" name="D4" value="-6.0" placeholder="请输入D4值"/> <br/><br/>
                    D5:<input type="text" name="D5" value="-3.0" placeholder="请输入D5值"/> <br/><br/>
                    <select name="data" hidden>
                        <option value="djd2_model">djd2_model</option><br/>
                    </select><br>
                    <input type="button" value="模型建立并优化" onclick="delay();run0()">
                </form>
            </c:if>

            <%--<c:if test="${empty ModelUpload}">
                <span class="FZ">请先导入模型</span>
            </c:if>--%>

            <c:if test="${!(empty ModelUpload)}">
                <span class="FZ">模型已优化完成</span>
            </c:if>
            <br/>

        </div>

    </div>

    <br/>

    <div class="row FC">
        <div class="col-md-4 col-md-offset-4">
            <div id="model_optimization" hidden class="FW">模型优化中，请勿关闭页面</div>
        </div>
    </div>

    <br/>

    <div class="row FC">
        <div class="col-md-4 col-md-offset-4">

            <c:if test="${(!(empty DataUpload))&&(!(empty ModelUpload))&&(empty Caculate_flag)}">
                <form  action="/Java_web/BRBServlet" method="post" enctype="multipart/form-data">

                    贡献度选择方式：&nbsp;&nbsp;
                    <input type="radio" name="choose" value="percent" checked onclick="run1()" /> 百分比
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="choose" value="number" onclick="run2()"/> 个数<br/><br/>
                    <span id="contribution1">贡献度百分比：</span><input type="text" name="per" value="80" placeholder="请输入百分比" id="contribution2"/><span id="contribution3">%</span> <br/><br/>

                    <input type="submit" value="计算"/>
                </form>
            </c:if>

            <div class="row FC">
                <c:if test="${(!(empty Caculate_flag))}">
                    <span class="FZ">计算完成</span>
                    <br/>
                    <br/>
                    <br/>
                    <c:if test="${((empty Optimation_flag))}">
                        <form action="/Java_web/PSOServlet" method="post" enctype="multipart/form-data">
                            <input type="submit" value="数据优化" onclick="warning2()"/>
                        </form>
                        <br/>
                        <div id = "warning" hidden class="FW">
                            数据优化中，请勿关闭页面
                        </div>
                    </c:if>


                </c:if>
                <c:if test="${((empty Caculate_flag))}">
                    <br/>
                    <br/>
                </c:if>
            </div>



            <div class="row FC">
                <div class="col-md-4 col-md-offset-4">
                    <c:if test="${(!(empty Optimation_flag))}">
                        <span class="FZ">优化完成</span>
                        <br/>
                        <br/>
                    </c:if>
                </div>

            </div>

        </div>
    </div>

    <br/>
    <br/>

        <div class="row FC">
            <div class="col-md-4 col-md-offset-4">
                <form action="/Java_web/afreshContribution" method="post" enctype="multipart/form-data">
                    <input type="submit" value="重新计算" />
                </form>
            </div>
        </div>

    <br/>
    <br/>
    <div class="row FC">
        <div class="col-md-4 col-md-offset-4">
            <form action="/Java_web/ClearAll" method="post" enctype="multipart/form-data">
                <input type="submit" value="重新开始" />
            </form>

        </div>
    </div>

    <%--<div class="btn-group" role="group" aria-label="..." style="margin-left: 47%">
        <a type="button" class="btn btn-primary" href="Step2.jsp" onclick="x()"> 返回步骤2 </a>
    </div>--%>

    <br/>

</div>

</body>

<style>
    .FZ {
        font-size: 20px;
        color: black;
        font-weight: bold;
    }

    .FC {
        text-align: center;
    }

    .FW {
        color: red;
    }

</style>

<script>

    var count0 = 0;
    function warning0() {
        var model_optimization = document.getElementById("model_optimization");

        model_optimization.hidden = false;

        if(count0 < 7) {
            model_optimization.innerText +=".";
            count0 += 1;
        }
        if(count0 == 7) {
            model_optimization.innerText = "模型优化中，请勿关闭页面";
            count0 = 0;
        }
    }

    function run0() {
       setInterval(warning0,500);
    }

    function submit() {
        var uo = document.getElementById("uo");
        uo.submit();
    }

    function delay() {
        //alert("111");
        setTimeout(submit,20000);
    }


    function run1() {
        var contribution1 = document.getElementById("contribution1");
        var contribution2 = document.getElementById("contribution2");
        var contribution3 = document.getElementById("contribution3");

        contribution1.innerText = "贡献度百分比：";

        contribution2.name = "per";
        contribution2.placeholder = "请输入百分比";
        contribution2.value = "80";

        contribution3.innerText = "%";

    }

    function run2() {
        var contribution1 = document.getElementById("contribution1");
        var contribution2 = document.getElementById("contribution2");
        var contribution3 = document.getElementById("contribution3");

        contribution1.innerText = "贡献度个数 ：";

        contribution2.name = "num";
        contribution2.placeholder = "请输入个数";
        contribution2.value = "3";

        contribution3.innerText = "个";
    }

    var count = 0;
    function warning() {
        var warning  = document.getElementById("warning")
        warning.hidden = false;

        if(count < 7) {
            warning.innerText +=".";
            count += 1;
        }
        if(count == 7) {
            warning.innerText = "数据优化中，请勿关闭页面";
            count = 0;
        }
    }
    function warning2() {
        setInterval(warning,500);
    }


</script>

</html>
